// if 判断
let target = 2;

if (target > 4) {
  console.log("额外执行xxx");
}
if (target > 5) {
  console.log("大于5");
} else {
  console.log("<=5");
}
if (target > 7) {
  console.log("7-10之间");
} else if (target > 4) {
  console.log("4-7之间");
} else {
  console.log("0-4之间");
}
console.log(Math.random());
console.log(Math.random() * 10);
console.log(Math.floor(Math.random() * 1000));
console.log(Math.floor(Math.random() * 1000));
console.log("----------------");
// 取 500 到 800之间的随机整数
//  [500,800) startWith endBefore
//   800-500 = 300 扩张量 500 偏移量
console.log(Math.floor(Math.random() * 300) + 500);
console.log(Math.floor(Math.random() * 300) + 500);
console.log(Math.floor(Math.random() * 300) + 500);
//  [23, 336]
console.log("----------------");
console.log(Math.floor(Math.random() * 313) + 23);
console.log(Math.floor(Math.random() * 313) + 23);
console.log(Math.floor(Math.random() * 313) + 23);
console.log(Math.floor(Math.random() * 313) + 23);

// 短路运算
let xiaozhang = {
  weight: 122,
  height: 188,
  age: 18,
  laugh: function () {
    console.log("0-------0");
  },
};

let xiaoming = {
  weight: 144,
  height: 185,
  age: 18,
  laugh: function () {
    console.log("xxx0-------0");
  },
};

// 赋值语句
// let p = xiaozhang.age ;
// let p = xiaozhang.age || 16;
// let q = xiaoming.age;
// let q = xiaoming.age || 16;
let p;
if (xiaoming.age) {
  p = xiaoming.age;
} else {
  p = 16;
}
// 带默认值 式 赋值方式

let q = xiaoming.age || 16;

xiaozhang.laugh();
// xiaoming.laugh();
if (xiaoming.laugh) {
  xiaoming.laugh();
}
// 存在后运行 保险式运行方法
xiaoming.laugh && xiaoming.laugh();

console.log("xxxxxxxxxxxx");
console.log("xxxxxxxxxxxx");
console.log("xxxxxxxxxxxx");

let p0 = 2;
// let ss = p0 < 5 ? "zhangsan" : "lisi";
let ss;
// if (p0 < 5) {
//   ss = { name: "zhangsan" };
// } else {
//   ss = { name: "lisi" };
// }
ss = p0 < 4 ? { name: "zhangsan" } : { name: "lisi" };

// 补充?
let some = ["zhangsan", "lisi"];
let any = {
  name: "zhangsan",
  age: 18,
};

//   "unsubmitted" "submitted" "audited"
let state = "audited";
switch (state) {
  case "unsubmitted":
    console.log("表单未提交");
    console.log("表单未提交");
    break;
  case "submitted":
    console.log("表单已提交未审核");
    console.log("表单已提交未审核");
    break;
  case "audited":
    console.log("表单已审核");
    console.log("表单已审核");
    break;
  default:
    console.log("表单状态不明");
    console.log("表单状态不明");
    break;
}
